package cn.iocoder.yudao.module.product.api.stock;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.product.api.stock.dto.StockInfoDTO;
import cn.iocoder.yudao.module.product.dal.dataobject.stockinfo.StockInfoDO;
import cn.iocoder.yudao.module.product.dal.mysql.stockinfo.StockInfoMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class StockInfoApiImpl implements StockInfoApi{

    @Resource
    private StockInfoMapper stockInfoMapper;

    @Override
    public List<StockInfoDTO> getStockList(Long ownerId, Integer ownerType) {
        LambdaQueryWrapperX<StockInfoDO> queryWrapperX = new LambdaQueryWrapperX<>();
        queryWrapperX.eq(StockInfoDO::getOwnerId,ownerId);
        queryWrapperX.eq(StockInfoDO::getOwnerType,ownerType);
        return BeanUtils.toBean(stockInfoMapper.selectList(queryWrapperX),StockInfoDTO.class);
    }
}
